package com.ss.android.article.base.feature.e;

import android.content.Context;
import android.os.Handler;
import android.os.Message;

import com.bytedance.article.common.c.TTUtils;

import com.bytedance.common.utility.Logger;
import com.ss.android.common.AbsApiThread;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.model.BaseArticle;
import com.ss.android.newmedia.NewMediaConstants;

import org.json.JSONObject;

public final class j extends AbsApiThread {
    private final Context a;
    private final Handler b;
    private int c;
    private String d;
    private BaseArticle e;
    private String f;
    private long g;
    private String h;

    public j(Context arg2, Handler arg3, int arg4, String arg5, BaseArticle arg6, String arg7, long arg8, String arg10) {

        Context v0 = arg2 != null ? arg2.getApplicationContext() : null;
        this.a = v0;
        this.b = arg3;
        this.c = arg4;
        this.d = arg5;
        this.e = arg6;
        this.f = arg7;
        this.g = arg8;
        this.h = arg10;
    }

    public final void run() {
        int v0 = 17;
        int v1 = 18;
        try {
            if (this.e != null && this.e.groupId > 0) {
                JSONObject v3 = new JSONObject();
                v3.put("group_id", this.e.groupId);
                v3.put("item_id", this.e.itemId);
                v3.put("aggr_type", this.e.aggrType);
                v3.put("report_type", this.c);
                v3.put("ad_id", this.g);
                if (!android.support.design.a.isTextEmpty(this.d)) {
                    v3.put("report_content", this.d);
                }

                if (!android.support.design.a.isTextEmpty(this.f)) {
                    v3.put("html", this.f);
                }

                String v2 = NewMediaConstants.feedback1ReportJsonUrl;
                if (!android.support.design.a.isTextEmpty(this.h)) {
                    v3.put("video_id", this.h);
                    v2 = NewMediaConstants.videoApiReportUrl;
                }

                v2 = NetworkUtils.executePost(-1, v2, v3.toString().getBytes(), NetworkUtils.CompressType.GZIP, "application/json; charset=utf-8");
                if (android.support.design.a.isTextEmpty(v2)) {
                } else if (!j.isApiSuccess(new JSONObject(v2))) {
                    Logger.w("ReportThread", "report error " + v2);
                } else if (this.b == null) {
                    v0 = v1;
                } else {

                    this.b.sendEmptyMessage(1034);
                    return;
                }
            }
        } catch (Throwable v0_1) {
            v0 = TTUtils.getErrorCode(this.a, v0_1);
        }
        if (this.b != null) {
            Message v1_1 = this.b.obtainMessage(1035);
            v1_1.arg1 = v0;
            this.b.sendMessage(v1_1);
        }
    }
}

